/**
 *  存储工具类
 **/

import Storage from "../Storage";
import LocalStorage from "../Storage";
import { getFormItem } from "../service/TaskService";

const KEY_ID = "key_user_id";
const KEY_SYS_FLAG = "wow";
const FORMITEM = "formItem";
const TOKEN = 'userToken'
const IDs = 'ids'
export function clear() {
  Storage.clear();
}

export function removeItem(key) {
  Storage.removeItem(key);
}

/* ************************ set get方法 ***************************** */

export function setID(id) {
  Storage.setItem(KEY_ID, id);
}
export function getID() {
  return Storage.getItem(KEY_ID);
}

export function setTOKEN(token) {
  Storage.setItem(TOKEN, token);
}
export function getTOKEN() {
  return Storage.getItem(TOKEN);
}

export function setIDs(ids,path) {
  Storage.setItem(IDs, JSON.stringify(ids));
  
}
export function getIDs() {
  return JSON.parse(Storage.getItem(IDs));
}
export function setInfo(Info,info) {
  Storage.setItem(Info, JSON.stringify(info));
  
}
export function getInfo(Info) {
  return JSON.parse(Storage.getItem(Info));
}

export function setSysFlag(sysFlag) {
  Storage.setItem(KEY_SYS_FLAG, sysFlag);
}

export function getSysFlag() {
  return Storage.getItem(KEY_SYS_FLAG);
}

export function setFormItem() {
  getFormItem().then(res => {
    const formInfo = JSON.stringify(res);
    return LocalStorage.setItem(FORMITEM, formInfo);
  });
}

export function getFormInfo() {
  return JSON.parse(LocalStorage.getItem(FORMITEM));
}

export function removeForm() {
  return LocalStorage.removeItem(FORMITEM);
}
